// 清除文件
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const path = require("path");
const vendors = [
  'react',
  'react-dom',
  'dva',
  "babel-polyfill",

  // ...其它库
];
const com = [
  "moment",
  "@antv/f2/lib/index-all",
  "lodash"
]
module.exports = {
  output: {
    path: path.resolve(__dirname, "public/dll"),
    filename: '[name].js',
    library: '[name]',
  },
  entry: {
    "lib": vendors,
    "com": com
  },
  plugins: [
    new CleanWebpackPlugin({
      root: path.resolve(__dirname, "public/dll")
    }),
    new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh\-cn/),
    new webpack.optimize.AggressiveMergingPlugin(),
    new webpack.optimize.UglifyJsPlugin(),
    new webpack.DllPlugin({
      path: path.resolve(__dirname, "public/dll/[name].manifest.json"),
      name: '[name]',
      context: __dirname,
    }),
  ],
}